package org.ntu.rtsearch.twitter;




public class Status {

	private String userId;
	
	private String text;
	
	private long timeStamp;
	
	private int rtCount;
	
	private boolean isFav;
	
	public static Status parseStatus(String str) throws Exception {
		String[] items = str.split("\\:\\^");
		if(items.length != 5)
			return null;
		return new Status(items);
	}
	
	public Status(String[] items) throws Exception {
		try {
			timeStamp = Long.parseLong(items[0]);
			userId = items[1];
			text = items[2];
			rtCount = "100+".equals(items[3]) ? 100 : Integer.parseInt(items[3]);
			isFav = ("0".equals(items[4])) ? true : false;
		} catch(Exception e) {
			for(int i = 0; i < items.length; i++) {
				System.out.println(items[i]);
			}
			throw e;
		}
	}

	public synchronized String getUserId() {
		return userId;
	}

	public synchronized void setUserId(String userId) {
		this.userId = userId;
	}

	public synchronized String getText() {
		return text;
	}

	public synchronized void setText(String text) {
		this.text = text;
	}

	public synchronized long getTimeStamp() {
		return timeStamp;
	}

	public synchronized void setTimeStamp(long timeStamp) {
		this.timeStamp = timeStamp;
	}

	public synchronized int getRtCount() {
		return rtCount;
	}

	public synchronized void setRtCount(int rtCount) {
		this.rtCount = rtCount;
	}

	public synchronized boolean isFav() {
		return isFav;
	}

	public synchronized void setFav(boolean isFav) {
		this.isFav = isFav;
	}
	
	
}
